<template>
  <div class="product-display">
    <div
      :class="['product-display-list', `product-display-list-active-` + amount]"
      v-for="(item, index) in list"
      :key="index"
    >
      <div class="product-display-list-header">
        <div class="product-header-img">
          <!-- <img class="image-100" :src="item.img_path" alt="" /> -->
          <el-image fit="fill" :src="item.img_path" lazy></el-image>
        </div>
        <div class="product-header-icon">
          <img
            v-if="item.is_collect == 0"
            class="image-100"
            src="@/assets/icon/cancel-collection.png"
            alt=""
          />
          <img
            v-else
            class="image-100"
            src="@/assets/icon/collection.png"
            alt=""
          />
        </div>
      </div>
      <div class="product-display-list-title">
        <div class="product-title-name using-single-drug">
          {{ item.name }}
        </div>
        <div class="product-title-look">查看详情</div>
      </div>
      <div class="product-display-show" @click="onProductInfo(item.id)">
        <div class="product-show">
          <div class="product-show-name">
            <div class="product-show-name-type">规格：</div>
            <div class="product-show-name-amount using-single-drug">
              {{ item.product_size_count }}
            </div>
          </div>
          <div class="product-show-name">
            <div class="product-show-name-type">材质：</div>
            <div class="product-show-name-amount using-single-drug">
              {{ item.texture }}
            </div>
          </div>
          <div class="product-show-name">
            <div class="product-show-name-type">重量：</div>
            <div class="product-show-name-amount using-single-drug">
              {{ item.weight_min }}
            </div>
          </div>
          <div class="product-show-name">
            <div class="product-show-name-type">工艺：</div>
            <div class="product-show-name-amount using-single-drug">
              {{ item.production_process }}
            </div>
          </div>
          <div class="product-show-name">
            <div class="product-show-name-type">收藏次数：</div>
            <div class="product-show-name-amount using-single-drug">
              {{ item.collect_num }}
            </div>
          </div>
          <div class="product-show-info">
            <div class="product-show-info-btn">查看详情</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'productDisplay',
  components: {},
  props: {
    amount: {
      type: String,
      default: '5',
    },
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    // 跳转到产品详情
    onProductInfo(id) {
      this.$router.push({ name: 'productInfo', query: { id } });
    },
  },
  mounted() {},
};
</script>

<style scoped lang="less">
.product-display {
  display: flex;
  flex-wrap: wrap;

  .product-display-list {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid #ebebeb;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 24px 14px 0;
    width: 180px;

    .product-display-list-header {
      position: relative;
      width: 100%;
      height: 178px;

      .product-header-img {
        width: 100%;
        height: 100%;

        /deep/ .el-image {
          width: 100%;
          height: 100%;
        }
      }

      .product-header-icon {
        position: absolute;
        right: 10px;
        top: 10px;
        cursor: pointer;
        width: 24px;
        height: 24px;
      }
    }
    .product-display-list-title {
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      align-items: center;
      padding: 0 14px;
      height: 64px;

      .product-title-name {
        width: 100%;
        font-size: 13px;
        color: #666666;
      }

      .product-title-look {
        cursor: pointer;
        font-size: 16px;
        color: #00091a;
      }
    }

    &:hover .product-display-show {
      display: block;

      .product-show {
        animation: showHeight 0.5s 1;
      }
    }
    // 底部展示框
    .product-display-show {
      display: none;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      cursor: pointer;
      height: 100%;
      border-radius: 4px;
      background-color: rgba(0, 0, 0, 0.5);

      .product-show {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 8px;
        height: 179px;
        background-color: #fff;

        .product-show-name {
          display: flex;

          .product-show-name-type {
            margin-bottom: 4px;
            font-size: 14px;
            color: #999999;
          }

          .product-show-name-amount {
            font-size: 14px;
            flex: 1;
            color: #00091a;
          }
        }

        .product-show-info {
          margin: 12px auto 0;
          width: 86px;
          text-align: center;
          height: 32px;
          line-height: 32px;
          background-color: #00359b;
          border-radius: 4px;

          .product-show-info-btn {
            font-size: 16px;
            color: #ffffff;
          }
        }
      }
    }
  }

  // 一行展示多少个
  .product-display-list-active-6:nth-child(6n) {
    margin: 0 0 14px 0;
  }
  .product-display-list-active-5:nth-child(5n) {
    margin: 0 0 14px 0;
  }
  .product-display-list-active-4:nth-child(4n) {
    margin: 0 0 14px 0;
  }
}
// 展示高度动画
@keyframes showHeight {
  0% {
    height: 0;
  }
  100% {
    height: 179px;
  }
}
</style>
